package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BasePageData;
import com.cskaoyan.bean.BaseParam;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Topic;
import com.cskaoyan.bean.wx.vo.TopicAndGoodsVo;
import com.cskaoyan.service.TopicService;
import com.cskaoyan.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/topic")
public class WechatTopicController {
    @Autowired
    TopicService topicService;

    /**
     * 通过分页显示专题接口
     *
     * @param param
     * @return
     */
    @GetMapping("list")
    public BaseRespVo list(BaseParam param) {
        BasePageData data = topicService.listInWechat(param);
        return BaseRespVo.ok(data);
    }

    /**
     * 通过专题id查询指定专题
     *
     * @param id
     * @return
     */
    @GetMapping("detail")
    public BaseRespVo detail(Integer id) {
        TopicAndGoodsVo topic = topicService.read(id);
        return BaseRespVo.ok(topic);
    }
    @GetMapping("related")
    public BaseRespVo related(Integer id) {
        //需要修改
        BaseParam baseParam = new BaseParam();
        baseParam.setLimit(Constant.WX_LIMIT);
        baseParam.setPage(Constant.WX_PAGE);
        BasePageData data = topicService.relatedInWechat(baseParam,id);
        return BaseRespVo.ok(data);
    }
}
